package com.ruoyi.peoplegroup.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.peoplegroup.domain.Partnercategory;
import com.ruoyi.peoplegroup.service.IPartnercategoryService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 合作单位类别Controller
 * 
 * @author gw
 * @date 2025-01-08
 */
@RestController
@RequestMapping("/partnercategory")
public class PartnercategoryController extends BaseController
{
    @Autowired
    private IPartnercategoryService partnercategoryService;

    /**
     * 查询合作单位类别列表
     */
    @RequiresPermissions("peoplegroup:partnercategory:list")
    @GetMapping("/list")
    public TableDataInfo list(Partnercategory partnercategory)
    {
        startPage();
        List<Partnercategory> list = partnercategoryService.selectPartnercategoryList(partnercategory);
        return getDataTable(list);
    }

    /**
     * 导出合作单位类别列表
     */
    @RequiresPermissions("peoplegroup:partnercategory:export")
    @Log(title = "合作单位类别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Partnercategory partnercategory)
    {
        List<Partnercategory> list = partnercategoryService.selectPartnercategoryList(partnercategory);
        ExcelUtil<Partnercategory> util = new ExcelUtil<Partnercategory>(Partnercategory.class);
        util.exportExcel(response, list, "合作单位类别数据");
    }

    /**
     * 获取合作单位类别详细信息
     */
    @RequiresPermissions("peoplegroup:partnercategory:query")
    @GetMapping(value = "/{categoryId}")
    public AjaxResult getInfo(@PathVariable("categoryId") Long categoryId)
    {
        return success(partnercategoryService.selectPartnercategoryByCategoryId(categoryId));
    }

    /**
     * 新增合作单位类别
     */
    @RequiresPermissions("peoplegroup:partnercategory:add")
    @Log(title = "合作单位类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Partnercategory partnercategory)
    {
        return toAjax(partnercategoryService.insertPartnercategory(partnercategory));
    }

    /**
     * 修改合作单位类别
     */
    @RequiresPermissions("peoplegroup:partnercategory:edit")
    @Log(title = "合作单位类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Partnercategory partnercategory)
    {
        return toAjax(partnercategoryService.updatePartnercategory(partnercategory));
    }

    /**
     * 删除合作单位类别
     */
    @RequiresPermissions("peoplegroup:partnercategory:remove")
    @Log(title = "合作单位类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{categoryIds}")
    public AjaxResult remove(@PathVariable Long[] categoryIds)
    {
        return toAjax(partnercategoryService.deletePartnercategoryByCategoryIds(categoryIds));
    }


    @GetMapping("/getAllpartnercates")
    public AjaxResult getAllpartnercates()
    {
        List<Partnercategory> list = partnercategoryService.selectPartnercategoryList(null);
        return success(list);
    }}
